<?php
require('lib/verify.php');
$_category = "wardkp";
$_title = "Register Character";
require('lib/head.php');

if($_GET['p'] == 2){
	$_title = "Register Character 2 of 4";
	$system_id = $_GET["id"];

	boxTop($_title);
	?><p>
	
	Now that we know whom you'll be raiding with, we need to know the exact, in-game name of the character you plan to raid on.
	</p><br>
	<p>
	<b>What is the in-game name of the character you plan to raid on?</b><br />
	<i>Please enter this exactly as it appears in game.</i>
	</p>
	<br />
	<form action="register-character.php" method="get"><br>
	<input type="hidden" name="p" value="3">
	<input type="hidden" name="system_id" value="<?php echo $system_id ?>">
	<input type="text" name="character_name" value="" style="width: 100px">
	<input type="submit" name="submit" value="Proceed" style="width: 100px">
	</form>
	
	<?php
	boxBot();
}
elseif($_GET['p'] == 3){
	$system_id = $_GET["system_id"];
	$character_name = $_GET["character_name"];

	$_title = "Register Character 3 of 4";	
	boxTop($_title);
	?>
	
	Now we know where, but how about as what?
	</p><br>
	<p>
	<b>Which class is your character?</b>
	</p>
	<br />
	<form action="register-character.php?p=4" method="get">
	<input type="hidden" name="p" value="4">
	<input type="hidden" name="system_id" value="<?php echo $system_id ?>">
	<input type="hidden" name="character_name" value="<?php echo $character_name ?>">
	<input type="submit" name="character_class" value="Death Knight" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Druid" style="width: 100px"><br /><br /><p>
	<input type="submit" name="character_class" value="Hunter" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Mage" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Paladin" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Priest" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Rogue" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Shaman" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Warlock" style="width: 100px"><br /><br />
	<input type="submit" name="character_class" value="Warrior" style="width: 100px"><br /><br />
	</form>
	
	<?php
	boxBot();
}
elseif($_GET['p'] == 4){
	$system_id = $_GET["system_id"];
	$character_name = $_GET["character_name"];
	$character_class = $_GET["character_class"];
	
	$sql = "select * from wm_systems where system_id='$system_id'";
	$result = $db->query($sql) or error('Unable to fetch wardkp system id', __FILE__, __LINE__, $db->error());
	$sys = $db->fetch_assoc($result);
	//echo $system_id;


	$_title = "Register Character 4 of 4";	
	boxTop($_title);
	?>
	Please verify the information below, and provided it's correct, submit it.
	</p><br>
	<p>
	<b>Please verify the information below and hit submit if it's correct.</b><br /><br />
	</p>
	<p>
	Raiding with: <b><?php echo $sys["system_name"] ?>, <?php echo $sys["system_faction"] ?> on <?php echo $sys["system_server"] ?></b><br />
	Character: <b><?php echo $character_name ?></b><br />
	Class: <b><?php echo $character_class ?></b><br /><br />
	</p>
	<br />
	<form action="register-character.php?p=5" method="get">
	<input type="hidden" name="p" value="5">
	<input type="hidden" name="system_id" value="<?php echo $system_id ?>">
	<input type="hidden" name="character_name" value="<?php echo $character_name ?>">
	<input type="hidden" name="character_class" value="<?php echo $character_class ?>">
	<input type="submit" name="submit" value="Submit" style="width: 100px"><br /><br /><p>
	</form>
	Wait!  The information isn't right!  <a href="register-character.php">Start Over</a>
	
	<?php

	boxBot();
}
elseif($_GET['p'] == 5){
	
	$system_id = $_GET["system_id"];
	$character_name = $_GET["character_name"];
	$character_class = $_GET["character_class"];
	$forum_id = $pun_user["id"];
	
	
	$sql = "update wm_characters set character_active = '0' where character_forum_id = '$forum_id'";
	$result = $db->query($sql);
	$sql = "insert into wm_characters (character_name, character_class, character_system_id, character_forum_id, character_active) values ('$character_name', '$character_class', $system_id, $forum_id, '1')";
	$result = $db->query($sql);
	

	$_title = "Register Character Complete";
	boxTop($_title);
	?>
	
	Thanks!  Your registration is now complete.
	</p><br>
	<p>
	<a href="<?php echo $war_http ?>">Return to wardkp</a>
	</p>
	
	<?php
	boxBot();
}

else {
	$_title = "Register Character 1 of 4";
	boxTop($_title);

	?>
	<p>

	First things first.
	</p><br>
	<p>
	<b>Who are you raiding with?</b>
	</p>
	<br />
	
	<?php
	$sql = "select * from wm_systems order by system_server asc, system_faction asc, system_name asc";
			$result = $db->query($sql) or error('Unable to fetch wardkp system listing', __FILE__, __LINE__, $db->error());
	while($sys = $db->fetch_assoc($result)) {
		echo '<a href="register-character.php?p=2&id='.$sys["system_id"].'">'.$sys["system_name"].', '.$sys["system_faction"].' on '.$sys["system_server"].'</a><br /><br />';
	}
	?>
	
	<?php
	boxBot();
}


?>

<?php
require('lib/foot.php');
?>

